<?php

namespace service\admin;

use epii\admin\center\App;
use model\AdminModel ;
use service\baseService;
use think\Db;

class AdminService extends BaseService
{
    protected static $model='model\AdminModel';
    public function __construct()
    {
        parent::__construct();
    }
    public static function getInfo($where){
        return AdminModel::getInfo($where);
    }
    public static function getInfoById($id){
        return AdminModel::getInfo(['id'=>$id]);
    }

    public static function getAjaxData($where)
    {
//        var_dump(self::$model);
        $table = self::$model::alias('a')->field('a.*,r.name as rname')
            ->join('role r', 'a.role=r.id')->order('a.id desc');
        return self::tableJsonData($table, $where, function ($data) {
            $data['addtime'] = date('Y-m-d H:i:s', $data['addtime']);
            $data['updatetime'] = date('Y-m-d H:i:s', $data['updatetime']);
            $data['status'] = $data['status'] == 'normal' ? "1" : "0";
            $data['hospital_name'] = $data['hospital_id']?HospitalService::getNameByKey($data['hospital_id']):'';
            return $data;
        });
    }


}